■<HTML> <!-- Copyright (c) Microsoft Corporation. All rights reserved.--> <HEAD> <TITLE>Static Ip Setting Page</TITLE> <SCRIPT LANGUAGE="VBScript"> <!-- Option Explicit 'Windows constants for key codes Public Const RightArrow = 39 Public Const LeftArrow = 37 Public Const EnterKey = 13 Public Const EscapeKey = 27 Public Const UpArrow = 38 Public Const DownArrow = 40 'Timer for idle timeout Dim iIdleTimeOut 'Text for wait information Dim strWaitText 'Flag for errors Dim bInErrorMode 'Flag for accessing netcfg component Dim bAccessDenied 'Ip address error text Dim strIpAddressInvalidText 'General error text for the task Dim strStaticIpErrorText '---------------------------------------------------------------------------- ' Function: Window_OnLoad ' Description: Initialization routine for the page ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: iIdleTimeOut,strWaitText,bInErrorMode,strIpAddressInvalidText '---------------------------------------------------------------------------- Sub Window_OnLoad() 'Localization manager object Dim objLocMgr 'Replacement strings Dim varReplacementStrings 'Resource ID for wait information text Const WAIT_TEXT = "&H40020012" 'Resource ID for Ip address error text Const IPADDRESS_ERROR_TEXT = "&H4002000A" 'Resource ID for task error text Const STATICIP_ERROR_TEXT = "&H40020007" 'SaHelper component object Dim objSaHelper 'Current static ip address Dim strStaticIP 'Current subnet mask Dim strSubnetMask 'Current default gateway Dim strDefaultGateway On Error Resume Next Err.Clear bInErrorMode = false bAccessDenied = false 'Create the localization manager Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager") If Err.number = 0 Then 'Get the strings strWaitText = objLocMgr.GetString("salocaluimsg.dll",WAIT_TEXT,varReplacementStrings) strIpAddressInvalidText = objLocMgr.GetString("salocaluimsg.dll",IPADDRESS_ERROR_TEXT,varReplacementStrings) strStaticIpErrorText = objLocMgr.GetString("salocaluimsg.dll",STATICIP_ERROR_TEXT,varReplacementStrings) Set objLocMgr = Nothing End If Err.Clear InformationText.innerText = strWaitText 'get the current configuration Set objSaHelper = CreateObject("ServerAppliance.SAHelper") If Err.number = 0 Then strStaticIP = objSaHelper.IpAddress If Err.number = 0 Then StaticIpEntry.IpAddress = strStaticIP End If Err.Clear strSubnetMask = objSaHelper.SubnetMask If Err.number = 0 Then StaticIpEntry.SubnetMask = strSubnetMask End If Err.Clear strDefaultGateway = objSaHelper.DefaultGateway If Err.number = 0 Then StaticIpEntry.Gateway = strDefaultGateway End If Err.Clear Set objSaHelper = Nothing End If StaticIpEntry.focus 'start the timer for idle timeout iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000) On Error Resume Next Err.Clear 'set the key codes for the page Dim objKeypad Set objKeypad = CreateObject("Ldm.SAKeypadController") If Err.number = 0 Then objKeypad.Setkey 0,UpArrow,TRUE objKeypad.Setkey 1,DownArrow,FALSE objKeypad.Setkey 2,LeftArrow,FALSE objKeypad.Setkey 3,RightArrow,FALSE objKeypad.Setkey 4,EscapeKey,FALSE objKeypad.Setkey 5,EnterKey,FALSE Set objKeypad = Nothing End If End Sub '---------------------------------------------------------------------------- ' Function: IdleHandler ' Description: Goes back to main page when timeout expires ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: None '---------------------------------------------------------------------------- Sub IdleHandler() window.history.go(-3) End Sub '---------------------------------------------------------------------------- ' Function: StaticIpEntry_OperationCanceled ' Description: Handles escape key press for static ip entry control ' Goes back to network page ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: None '---------------------------------------------------------------------------- Sub StaticIpEntry_OperationCanceled() If bInErrorMode = false Then window.history.go(-1) Else bInErrorMode = false End If End Sub '---------------------------------------------------------------------------- ' Function: StaticIpEntry_KeyPressed ' Description: Handles any key press for static ip entry control ' Resets the idle timeout timer ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: None '---------------------------------------------------------------------------- Sub StaticIpEntry_KeyPressed() window.clearTimeOut(iIdleTimeOut) iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000) End Sub '---------------------------------------------------------------------------- ' Function: StaticIpEntry_StaticIpEntered ' Description: Handles enter key press for static ip entry control ' Sets the static ip and displays the result ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: None '---------------------------------------------------------------------------- Sub StaticIpEntry_StaticIpEntered() 'SaHelper object pointer Dim objSaHelper On Error Resume Next Err.Clear If bInErrorMode = false and bAccessDenied = false Then 'Display the wait text InformationText.style.display = "" 'Hide the data entry control StaticIpEntry.style.display ="none" Set objSaHelper = CreateObject("ServerAppliance.SAHelper") 'If object is successfully created If Err.Number = 0 Then objSaHelper.SetStaticIp StaticIpEntry.IpAddress, StaticIpEntry.SubnetMask, StaticIpEntry.Gateway Set objSaHelper = Nothing End If 'Ip address successfully set If Err.Number = 0 Then window.history.go(-1) 'Error accessing the netcfg component ElseIf Err.Number = 70 Then bAccessDenied = true InformationText.innerText = strStaticIpErrorText 'Something failed, display error information Else InformationText.innerText = strIpAddressInvalidText bInErrorMode = true End If ElseIf bAccessDenied = true Then window.history.go(-1) Else bInErrorMode = false End If End Sub '---------------------------------------------------------------------------- ' Function: KeyDown ' Description: Handles key presses ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: None '---------------------------------------------------------------------------- Sub KeyDown() 'clear the timeout and restart it window.clearTimeOut(iIdleTimeOut) iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000) 'If escape key is hit, go back to tasks page If window.event.keycode = EscapeKey or window.event.keycode = EnterKey Then StaticIpEntry.style.display = "" StaticIpEntry.focus InformationText.style.display = "none" InformationText.innerText = strWaitText End If End Sub --> </SCRIPT> </HEAD> <BODY RIGHTMARGIN=0 LEFTMARGIN=0 OnKeydown="KeyDown"> <OBJECT STYLE="position:absolute; top:0; left=0; WIDTH=128; HEIGHT=64;" ID="StaticIpEntry" CLASSID="CLSID:D8A69FA0-25FE-4B9C-BBCE-81D6EBE2FDC0"> </OBJECT> <A ID="InformationText" STYLE="position:absolute; top:0; left:0; font-size:10; font-family=arial; display=none;" > </A> </BODY> </HTML>